package com.kuang.controller;

import com.kuang.springcloud.pojo.User;
import com.kuang.springcloud.service.UserClientService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@RestController
public class consumerUserController {

    /**
     * 使用feign 接口调用方式
     * @return
     */
    @Resource
    private UserClientService userClientService;

    @GetMapping("/user/getOne/{userId}")
    public User getUser(@PathVariable("userId") Integer userId){
        return userClientService.selectOne(userId);
    }
    @GetMapping("/user/getAll")
    public List<User> getUserAll(){
       return userClientService.selectAll();
    }
    @RequestMapping("/user/add")
    public Boolean addUser(User user){
      return userClientService.addOne(user);
    }
}
